package com.example.wangyi.utils;

import com.example.wangyi.gson.DoubleDefault0Adapter;
import com.example.wangyi.gson.LongDefault0Adapter;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
 * 版权：xx公司
 *
 * @author:created by
 * 版本：
 * 创建日期：2021/1/19 14h
 * 描述：GetGson
 */
public class GetGson {

    private static Gson gson;

    public static Gson buildGson() {
        if(gson == null) {
            gson =new GsonBuilder()
                    .registerTypeAdapter(Integer.class,new IntegerDefault0Adapter())
                    .registerTypeAdapter(int.class,new IntegerDefault0Adapter())
                    .registerTypeAdapter(Double.class,new DoubleDefault0Adapter())
                    .registerTypeAdapter(double.class,new DoubleDefault0Adapter())
                    .registerTypeAdapter(Long.class,new LongDefault0Adapter())
                    .registerTypeAdapter(long.class,new LongDefault0Adapter())
                    .create();
        }
        return gson;
    }
}
